<div ng-controller="order_DirectorC">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">计划单管理</h1>
    </div>
    <div class="wrapper-md" style="text-align: center;">
        <div class="panel panel-default">
            <div class="panel-heading">
                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12" style="float: right">
                    <a class="btn btn-sm btn-default" href={{myurl}}>
                        <i class="fa fa-cloud-download text"></i>
                        <span class="text">导出</span>
                    </a>
                </div>
                <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 input-group">
                    <div class="input-group">
                        <span class="input-group-addon">模糊查找</span>
                        <input type="text" class="form-control" placeholder="客户名\客户经理\供应商模糊查询" ng-model="findname">
                        <span class="input-group-addon">按状态查找</span>
                        <select class="form-control" ng-model="typename">
                            <option value="">请选择状态</option>
                            <option value="0">待确认</option>
                            <option value="1">驻厂确认</option>
                            <option value="2">已发货</option>
                            <option value="3">已收货</option>
                            <option value="4">已结算</option>
                            <option value="5">完结</option>
                            <option value="6">取消</option>
                            <option value="7">审核通过</option>
                            <option value="8">已退货</option>
                            <option value="9">已退款</option>
                        </select>
                        <span class="input-group-addon">按日期查找</span>
                        <input type="date" class="form-control" placeholder="按日期查找" ng-model="qTime">
                        <span class="input-group-btn">
                            <button class="btn btn-default" type="button" ng-click="find()">查找</button>
                        </span>
                    </div>
                </div>
            </div>
            <div class="table-responsive">
                <table id="example1" class="table table-striped b-t b-light table-bordered">
                    <thead>
                        <tr>
                            <th style="text-align: center;">客户名</th>
                            <th style="text-align: center;">客户经理</th>
                            <th style="text-align: center;">供应商</th>
                            <th style="text-align: center;">类型</th>
                            <th style="text-align: center;">金额/重量t</th>
                            <th style="text-align: center;">状态</th>
                            <th style="text-align: center;">地址</th>
                            <th style="text-align: center;">备注</th>
                            <th style="text-align: center;">状态</th>
                            <th style="text-align: center;">创建时间</th>
                            <th style="text-align: center;">详情</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="item in orders">
                            <td style="width:10%">{{item.Customer.ShortName}}</td>
                            <td style="width:10%">{{item.Creater.Name}}</td>
                            <td style="width:10%">{{item.Provider.Name}}</td>
                            <td style="width:5%" ng-if="item.Provider.ProviderType == 0">钢厂</td>
                            <td style="width:5%" ng-if="item.Provider.ProviderType == 1">仓库</td>
                            <td style="width:5%" ng-if="item.Provider.ProviderType == 2">贸易商</td>
                            <td style="width:15%">{{item.Total | number:2}}/{{item.Weight | number:3}}t</td>
                            <td style="width:8%">
                                <span ng-if="item.IsFullPayment">先款</span>&nbsp;
                                <span ng-if="item.IsStandard">标件</span>
                            </td>
                            <td style="width:8%">{{item.District.Name}}</td>
                            <td>{{item.Remarks}}</td>
                            <td style="width:8%" ng-if="item.State == 0">待确认</td>
                            <td style="width:8%" ng-if="item.State == 1">驻厂确认</td>
                            <td style="width:8%" ng-if="item.State == 2">已发货<span ng-if="item.IsSettlement">,已结算</span></td>
                            <td style="width:8%" ng-if="item.State == 3">已收货</td>
                            <td style="width:8%" ng-if="item.State == 4">已结算</td>
                            <td style="width:8%" ng-if="item.State == 5">完结</td>
                            <td style="width:8%" ng-if="item.State == 6">取消</td>
                            <td style="width:8%" ng-if="item.State == 7">审核通过</td>
                            <td style="width:8%" ng-if="item.State == 8">已退货</td>
                            <td style="width:8%" ng-if="item.State == 9">已退款</td>
                            <td style="width:10%">{{item.CreateTime}}</td>
                            <td style="width:10%">
                                <button class="btn btn-sm btn-default" ng-click="detail($index)">
                                    <i class="fa fa-file-text-o text"></i>
                                    <span class="text">详情</span>
                                </button>
                            </td>

                        </tr>
                    </tbody>
                </table>
                <div class="panel-heading" my-pagination get-page-data="getData" mypagedata="pageData"></div>
            </div>
        </div>
    </div>
</div>
<script>
    angular.module('app')
        //计划单列表控制器
    .controller("order_DirectorC", function ($scope, $state, $http) {
        $scope.pageData = {};
        $scope.pageData.Page = 0;
        $scope.findname = "";
        $scope.typename = "";
        $scope.order = "取消";
        $scope.qTime = new Date();
        $scope.pageData.Rows = $scope.defPageRows;
        $scope.myurl = "/api/Director/ExpOrderList?state=&type=" + $scope.typename + "&createTime=" + $scope.qTime + "&name=" + $scope.findname;
        $scope.getData = function (p, r) {
            if (p) {
                p = p < 1 ? 1 : p;
            } else p = 1;
            if (r) {
            } else r = $scope.defPageRows;
            $http.get("../api/Director/OrderList", { params: { page: p, rows: r, createTime: $scope.qTime, name: $scope.findname, state: $scope.typename, type: "" } })
            .then(function (res) {
                $scope.orders = res.data.Data;
                $scope.pageData = res.data;
                //过滤取消的计划单
                $scope.guo = function () {
                    for (var i = 0; i < $scope.orders.length; i++) {
                        if ($scope.orders[i].State == 6) {
                            console.log();
                            $scope.orders[i].State = " ";
                        }
                    }
                }; $scope.guo();
            })
            .then(function (error) {
                if (error) {
                    alert("数据获取失败");
                }
            });
        };
        $scope.detail = function (index) {
            $state.go('app.Director_OrderDetail', {
                orderid: JSON.stringify($scope.orders[index].Id)
            });
        };
        $scope.find = function () {
            $scope.getData(1, $scope.pageData.Rows);
        };
        //加载数据
        $scope.getData(1, $scope.pageData.Rows);
    })

</script>